///PHILOTES Source Code.  (C)2012 PhiloLabs
#pragma once

#ifndef __OGRE_POSE_H
#define __OGRE_POSE_H

#include "OgrePrerequisites.h"
#include "OgreString.h"
#include "OgreHardwareVertexBuffer.h"
#include "math/vector3.h"
#include "OgreIteratorWrappers.h"

namespace Ogre {

	
	
	
	class _OgreExport Pose : public MemAlloc_Animation
	{
	public:
		
		Pose(ushort target, const String& name = StringUtil::BLANK);
		virtual ~Pose();
		/// Return the name of the pose (may be blank)
		const String& getName(void) const { return mName; }
		/// Return the target geometry index of the pose
		ushort getTarget(void) const { return mTarget; }
		/// A collection of vertex offsets based on the vertex index
		typedef map<size_t, Vector3>::type VertexOffsetMap;
		/// An iterator over the vertex offsets
		typedef MapIterator<VertexOffsetMap> VertexOffsetIterator;
		/// An iterator over the vertex offsets
		typedef ConstMapIterator<VertexOffsetMap> ConstVertexOffsetIterator;
		/// A collection of normals based on the vertex index
		typedef map<size_t, Vector3>::type NormalsMap;
		/// An iterator over the vertex offsets
		typedef MapIterator<NormalsMap> NormalsIterator;
		/// An iterator over the vertex offsets
		typedef ConstMapIterator<NormalsMap> ConstNormalsIterator;
		/// Return whether the pose vertices include normals
		bool getIncludesNormals() const { return !mNormalsMap.empty(); }

		
		void addVertex(size_t index, const Vector3& offset);

		
		void addVertex(size_t index, const Vector3& offset, const Vector3& normal);

		
		void removeVertex(size_t index);

		
		void clearVertices(void);

		
		ConstVertexOffsetIterator getVertexOffsetIterator(void) const;
		
		VertexOffsetIterator getVertexOffsetIterator(void);
		
		const VertexOffsetMap& getVertexOffsets(void) const { return mVertexOffsetMap; }

		
		ConstNormalsIterator getNormalsIterator(void) const;
		
		NormalsIterator getNormalsIterator(void);
		
		const NormalsMap& getNormals(void) const { return mNormalsMap; }

		
		const HardwareVertexBufferSharedPtr& _getHardwareVertexBuffer(const VertexData* origData) const;

		
		Pose* clone(void) const;
	protected:
		/// Target geometry index
		ushort mTarget;
		/// Optional name
		String mName;
		/// Primary storage, sparse vertex use
		VertexOffsetMap mVertexOffsetMap;
		/// Primary storage, sparse vertex use
		NormalsMap mNormalsMap;
		/// Derived hardware buffer, covers all vertices
		mutable HardwareVertexBufferSharedPtr mBuffer;
	};
	typedef vector<Pose*>::type PoseList;

	
	

}

#endif
